Model III ROM Explained - Part 3
Page Customization
Navigation
Disassembly
Related Pages
2003 - UE ERROR entry point.
2008-2038 - LEVEL II BASIC AUTO ROUTINE
THE AUTO [BEGGINNING LINE[,[INCREMENT]]] COMMAND IS USED TO AUTOMATICALLY GENERATE LINE NUMBERS FOR LINES TO BE INSERTED. BEGINNING LINE IS USED TO SPECIFY THE INITAL LINE (10 IS ASSUMED IF OMMITED) AND THE INCREMENT IS USED TO SPECIFY THE INCREMENT USED TO GENERATE THE NEXT LINE #. IF ONLY A COMMA IS USED AFTER THE BEGGINING LINE, THE OLD INCREMENT IS USED.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
Note: 40E4H-40E5H holds AUTO increment.
NOTE: The routine at 1E5A converts the ASCII string pointed to by HL to an integer deposited into DE. If the routine finds a non-numerica character, the conversion is stopped.
Note: 40E4H-40E5H holds AUTO increment.
Note: 40E2H-40E3H holds Current BASIC line number.
2039-2066 - LEVEL II BASIC IF ROUTINE
Notes:
- 2C is a , in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- CAH is a THEN token.
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
2056 - LEVEL II BASIC ELSE ROUTINE
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Notes:
- 95H is a ELSE in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
2067-206E - LEVEL II BASIC LPRINT ROUTINE
- Note: 409CH holds the current output device flag:
- -1=cassette,
- 0=video; or
- 1=printer.
Differences between M1 and M3 ROMs: All of the changes from 206DH - 20F7H first appeared in the "new" ROMs of the Model I. The changes were made to allow the use of multiple @'s in a PRINT statement.
206F-2177 - LEVEL II BASIC PRINT ROUTINE
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
- 4020H-4021H: Holds the video memory address of the current cursor position.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2C
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- BCH is a TAB in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- 2CH is a , in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- 3BH is a ; in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).
The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
- Note: 409CH holds the current output device flag:
- -1=cassette,
- 0=video; or
- 1=printer.
Note: 409BH holds the printer carriage position.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Note: 409DH holds the size of line on the video display.
Note: 40A6H holds the current cursor line position.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Note: 40A6H holds the current cursor line position.
20FE - This routine outputs a carriage return (0DH) to a device determined by flag stored at (409CH)
NOTE: This routine may be CALLed at 20F9H, in which case it will not perform the above action if the video display cursor is already positioned at the beginning of a line, as determined by checking the contents of the cursor position flag at 40A6H (if zero, cursor is at start of line). This routine CALLs the routine at 032AH and also CALLs a Disk BASIC link at 41D0H.
In NEWDOS 2.1, this is called when skipping to next line on a video during a BASIC output operation.
2108 - This is the jump point for a continuation of the "PRINT#" code
In NEWDOS 2.1, this is called at the start of PRINT on cassette and during PRINT TAB.
- Note: 409CH holds the current output device flag:
- -1=cassette,
- 0=video; or
- 1=printer.
- M will be set if the value in A is negative.
- P will be set if the value in A is positive or zero.
Note: 409BH holds the printer carriage position.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Note: 409EH holds the size of line on the printer.
Note: 40A6H holds the current cursor line position.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
2137 - TAB logic
This routine is the TAB function for video or printer (determined by flag at 409CH). On entry: E register contains desired TAB position, HL points to start of message to be displayed (or zero byte if no message). This routine does extensive string processing and may not be the most efficient method of achieving the desired result, particularly if it is desired only to tab over a number of spaces. Also, this routine CALLs several Disk BASIC links which may have to be "plugged". 2169 - Reset device type flag at 409CH to zero (output to video display), also turns off cassette drive if necessary. CALLs Disk BASIC link at 41BEH prior to return.
Difference between M1 and M3 ROMs: This also first appeared in the "new" ROMs of the Model I, as part of an AND 7FH instruction located at 213AH. In the original version the instruction was AND 3FH. The operand of the instruction sets the maximum argument for the TAB function, thus the early TRS-80's could only handle a maximum TAB (63) while the latest Models can go as high as TAB (127).
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
To use a ROM call to locate the cursor at position n on the current display line, where n is an integer between 0 and 3FH, inclusive, first load the E register with the value of n and then load the HL register pair with the address of a zero byte in memory. Once that's done CALL 213FH.
- NOTE 1: The cursor position cannot be moved backward by this procedure. If n is not greater than the current cursor position on the line, no change will occur.
- NOTE 2: To locate the cursor at a given position on the screen (the function of the PRINT@ command in BASIC), the simplest procedure is to modify the cursor position bytes, which are located at 4020H-4021H. The address contained in these memory cells is that of the position in video memory (3C00H-3FFFH) at which the (abstract) cursor resides. This cursor position controls subsequent printing via the subroutine at 28A7H
- DISK SYSTEM CAUTION: The subroutine at 213FH has three exits to DISK BASIC, with RAM transfer points at 41BEH, 41C1H, and 41D3H. To use this routine safely, either be certain that DISK BASIC is in place, or have your assembly language program fill locations 41BEH, 41C1H, and 41D3H with RET's (C9H), before calling the routine.
- Note: 409CH holds the current output device flag:
- -1=cassette,
- 0=video; or
- 1=printer.
Note: 409BH holds the printer carriage position.
Note: 40A6H holds the current cursor line position.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Difference between M1 and M3 ROMs: This corrects a jump back into the revised PRINT command routine.
2169 - This routine resets the device type flag at 409CH to zero (output to video display), also turns off cassette drive if necessary. CALLs Disk BASIC link at 41BEH prior to return
- Note: 409CH holds the current output device flag:
- -1=cassette,
- 0=video; or
- 1=printer.
- Note: 409CH holds the current output device flag:
- -1=cassette,
- 0=video; or
- 1=printer.
In NEWDOS 2.1, this initializes the system output device.
2178-217E - MESSAGE STORAGE LOCATION FOR REDO MESSAGE
217F-2285 - LEVEL II BASIC INPUT AND READ ROUTINES
We are here when the data that was typed in or in "DATA" statements is improperly formatted. For "INPUT" we start again. For "READ" we give a syntax error at the data line.
Note: 40DEH holds READ flag.
Note: 40A9H holds Cassette input flag.
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
Note: 40E6H-40E7H holds Temporary storage location.
219A - INPUT logic
In NEWDOS 2.1 this is called at the beginning of INPUT processing.
Note: 40A9H holds cassette input flag.
Note: 40A7H-40A8H holds the input Buffer pointer.
Notes:
- 0DH is a ENTER in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Note: 40A7H-40A8H holds the input Buffer pointer.
Notes:
- 22H is a " in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
21EF - "READ" logic
Note: 40FFH-4100H holds READ pointer.
Note: 40DEH holds READ flag.
N THE PROCESSING OF DATA AND READ STATEMENTS: ONE POINTER POINTS TO THE DATA (IE THE NUMBERS BEING FETCHED) AND ANOTHER POINTS TO THE LIST OF VARIABLES. THE POINTER INTO THE DATA ALWAYS STARTS POINTING TO A TERMINATOR -- A , : OR END-OF-LINE
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE AT THIS POINT WE HAVE A VARIABLE WHICH WANTS DATA AND SO WE MUST GET DATA OR COMPLAIN
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Note: 40DEH holds READ flag.
Note: 40A9H holds Cassette input flag.
In NEWDOS 2.1, this is called during READ processing when a variable has been read.
NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).
The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
- NOTE: 0E65H converts the ASCII string pointed to by HL to its double precision equivalent; with output left in REG 1).
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
226F-2285 - For ROM v1.2
Note: 40DEH holds READ flag.
In NEWDOS 2.1 this is called at the end of READ processing.
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
2286-2295 - MESSAGE STORAGE LOCATION
2296-22B5 - FIND THE NEXT DATA STATEMENT ROUTINE
SUBROUTINE TO FIND DATA. IN THE 4K "DATA" MUST BE AT THE START OF THE LINE SO THE SEARCH IS MADE USING THE LINKS AT THE START OF EACH LINE. IN THE 8K AND EXTENDED THE SEARCH IS MADE BY USING THE EXECUTION CODE FOR DATA TO SKIP OVER STATEMENTS. THE START WORD OF EACH STATEMENT IS COMPARED WITH $DATA. EACH NEW LINE NUMBER IS STORED IN DATLIN SO THAT IF AN ERROR OCCURS WHILE READING DATA THE ERROR MESSAGE WILL GIVE THE LINE NUMBER OF THE ILL-FORMATTED DATA
Note: 40DAH-40DBH holds DATA line number.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
22B6-2336 - LEVEL II BASIC NEXT ROUTINE
A "FOR" ENTRY ON THE STACK HAS THE FOLLOWING FORMAT:
- LOW ADDRESS
- TOKEN ($FOR IN HIGH BYTE) 1 BYTES
- A POINTER TO THE LOOP VARIABLE 2 BYTES
- A BYTE REFLECTING THE SIGN OF THE INCREMENT 1 BYTE
- THE STEP 4 BYTES
- THE UPPER VALUE 4 BYTES
- THE LINE # OF THE "FOR" STATEMENT 2 BYTES
- A TEXT POINTER INTO THE "FOR" STATEMENT 2 BYTES
- HIGH ADDRESS
Note: 40DFH-40E0H holds Used by DOS.
Note: 40E8H-40E9H holds Stack pointer pointer.
NOTE: The routine at 0A0CH algebraically compares the single precision value in BC/DE to the single precision value REG 1.
The results are stored in A as follows:
- A=0 if REG 1 = BCDE
- A=1 if REG 1>BCDE; and
- A=FFH if REG 1<BCDE.
Note: 40AFH holds Current number type flag.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
If DE > HL then A will be -1;
If DE < HL then A will b +1; and
If DE = HL then A will be 0.
NOTE:40A2H-40A3H holds the current BASIC line number.
Note: 40E8H-40E9H holds Stack pointer pointer.
Note: 40DFH-40E0H holds Used by DOS.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
2335-27C8 - EVALUATE EXPRESSION
This routine evaluates a BASIC expression pointed to by the HL and stores the result in the ACC. The expression must be terminated with zero byte, comma, right bracket or colon. After execution, HL will point to the delimiter and, in the case of string expressions, the ACC will contain the address of the first of three bytes that contain string length and string address. Note that the stack is used frequently and the machine should be formatted for RUN mode in order to use this routine.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
Note: 40F3H-40F4H holds temporary storage location.
Note: 40F3H-40F4H holds temporary storage location.
NOTE: A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Note: 40D8H-40D9H holds Temporary storage location.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40D8H-40D9H holds Temporary storage location.
E Token
0 +
1 -
2 *
3 /
4 @@
5 AND
6 OR
Note: 40AFH holds Current number type flag.
2377 - PRINT@ logic.
THIS CODE PUSHES THE CURRENT VALUE IN THE FAC ONTO THE STACK, EXCEPT IN THE CASE OF STRINGS IN WHICH IT CALLS TYPE MISMATCH ERROR. [D] AND [E] ARE PRESERVED. THIS CODE IS ALSO USED BY USER-DEFINED FUNCTION VALUE SAVING, WHICH ENTERS AT PUSVAL WITH CARRY SET.
Note: 40AFH holds Current number type flag.
Note: 411DH-4124H holds REG l.
06 F1
Note: 40D8H-40D9H holds Temporary storage location.
FOR EXPONENTIATION WE WANT TO FORCE THE CURRENT VALUE IN THE FAC TO BE SINGLE PRECISION. WHEN APPLICATION TIME COMES WE FORCE THE RIGHT HAND OPERAND TO SINGLE PRECISION AS WELL
FOR "AND" AND "OR" AND "\" AND "MOD" WE WANT TO FORCE THE CURRENT VALUE IN THE FAC TO BE AN INTEGER, AND AT APPLICATION TIME FORCE THE RIGHT HAND OPERAND TO BE AN INTEGER
HERE TO BUILD AN ENTRY FOR A RELATIONAL OPERATOR STRINGS ARE TREATED SPECIALLY. NUMERIC COMPARES ARE DIFFERENT FROM MOST OPERATOR ENTRIES ONLY IN THE FACT THAT AT THE BOTTOM INSTEAD OF HAVING RETAOP, DOCMP AND THE RELATIONAL BITS ARE STORED. STRINGS HAVE STRCMP,THE POINTER AT THE STRING DESCRIPTOR, DOCMP AND THE RELATIONAL BITS. ;
NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).
The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
APPLOP IS RETURNED TO WHEN IT IS TIME TO APPLY AN ARITHMETIC OR NUMERIC COMPARISON OPERATION. THE STACK HAS A DOUBLE BYTE ENTRY WITH THE OPERATOR NUMBER AND THE VALTYP OF THE VALUE ON THE STACK. APPLOP DECIDES WHAT VALUE LEVEL THE OPERATION WILL OCCUR AT, AND CONVERTS THE ARGUMENTS. APPLOP USES DIFFERENT CALLING CONVENTIONS FOR EACH VALUE TYPE.
- INTEGERS: LEFT IN [D,E] RIGHT IN [H,L]
- SINGLES: LEFT IN [B,C,D,E] RIGHT IN THE FAC
- DOUBLES: LEFT IN FAC RIGHT IN ARG
Note: 40B0H holds Temporary storage location.
Note: 40AFH holds Current number type flag.
THE STACK OPERAND IS DOUBLE PRECISION, SO THE FAC MUST BE FORCED TO DOUBLE PRECISION, MOVED INTO ARG AND THE STACK VALUE POPED INTO THE FAC
Note: 411DH-4124H holds REG l.
Note: 40B0H holds Temporary storage location.
THE FAC IS DOUBLE PRECISION AND THE STACK IS EITHER INTEGER OR SINGLE PRECISION AND MUST BE CONVERTED
Note: 40AFH holds Current number type flag.
THIS IS THE CASE WHERE THE STACK IS SINGLE PRECISION AND THE FAC IS EITHER SINGLE PRECISION OR INTEGER
THIS IS THE CASE WHERE THE FAC IS SINGLE PRECISION AND THE STACK IS AN INTEGER.
2490 - Integer divide
(ACC=DE / HL) Result will be in single-precision (NTF=4) and will be in the ACC.
Divides DE by HL. Both values are converted to single precision before the division is started. The quotient is left in REG l; the mode flag is updated. The orginal contents of the DE and HL register sets are lost.
Note: To use a ROM call to divide two integers store the dividend in the DE register pair, and store the divisor in HL and then CALL 2490H. The result is stored in single precision format (since it is not likely to be an integer) in 4121H-4124Hin approximately 5.1 milliseconds.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Notes:
- CDH is a + in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- 2EH is a . in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- CEH is a - in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- 22H is a " in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- CBH is a NOT token.
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- 26H is a & in ASCII
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
Notes:
- C3H is a ERR token.
- A CP will return Z if there is a match against Register A, and NZ if not a match against Register A.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 409AH holds the RESUME flag.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40EAH-40EBH holds the line number with error.
24E7-24FE - "VARPTR" logic
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
24FF - Other Function Routine
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2532 - Binary Minus Routine
Note: 40F3H-40F4H holds Temporary storage location.
2540 - This routine loads a variable to the ACC and sets the NTF.
The HL must point to the ASCII variable name. After execution the HL will point to the character following the last character of the variable used. The value of the variable will be loaded in the ACC. For strings however (NTF=3), the ACC will contain the address of the first three bytes which contain the string length and string address (see Level II BASIC manual). Also note that if the variable cannot be found it will be created and given a value of zero.
NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).
The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
254E - This routine is for "SNG" to "MID$"
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
MOST FUNCTIONS TAKE A SINGLE ARGUMENT.
THE RETURN ADDRESS OF THESE FUNCTIONS IS A SMALL ROUTINE THAT CHECKS TO MAKE SURE VALTYP IS 0 (NUMERIC) AND POPS OFF THE TEXT POINTER. SO NORMAL FUNCTIONS THAT RETURN STRING RESULTS (I.E. CHR$) MUST POP OFF THE RETURN ADDRESS OF LABBCK, AND POP OFF THE TEXT POINTER AND THEN RETURN TO FRMEVL.
THE SO CALLED "FUNNY" FUNCTIONS CAN TAKE MORE THAN ONE ARGUMENT. THE FIRST OF WHICH MUST BE STRING AND THE SECOND OF WHICH MUST BE A NUMBER BETWEEN 0 AND 256. THE TEXT POINTER IS PASSED TO THESE FUNCTIONS SO ADDITIONAL ARGUMENTS CAN BE READ. THE TEXT POINTER IS PASSED IN [D,E]. THE CLOSE PARENTHESIS MUST BE CHECKED AND RETURN IS DIRECTLY TO FRMEVL WITH [H,L] SETUP AS THE TEXT POINTER POINTING BEYOND THE ")". THE POINTER TO THE DESCRIPTOR OF THE STRING ARGUMENT IS STORED ON THE STACK UNDERNEATH THE VALUE OF THE INTEGER ARGUMENT (2 BYTES)
FIRST ARGUMENT ALWAYS STRING -- SECOND INTEGER.
CHECK IF SPECIAL COERCION MUST BE DONE FOR ONE OF THE TRANSCENDENTAL FUNCTIONS (RND, SQR, COS, SIN, TAN, ATN, LOG, AND EXP) THESE FUNCTIONS DO NOT LOOK AT VALTYP, BUT RATHER ASSUME THE ARGUMENT PASSED IN THE FAC IS SINGLE PRECISION, SO FRCSNG MUST BE CALLED BEFORE DISPATCHING TO THEM.
258C - This routine will do a relational comparison of two strings.
It will load A with the length of the first string and BC with the string's address. Then it will load D with the length of the second string and HL with the string's address. - "STRCMP"
THE FOLLOWING ROUTINE COMPARES TWO STRINGS; ONE WITH DESC IN [D,E] OTHER WITH DESC. IN [FACLO, FACLO+1]
- A=0 IF STRINGS EQUAL
- A=377 IF B,C,D,E .GT. FACLO
- A=1 IF B,C,D,E .LT. FACLO
If the values match, set the current result in zero. If they do not match, set the current result to -1.
25C4 - NOT Handler
25D9 - The RST 20H code is located here. - This is the TEST DATA MODE, which determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH) - "GETYPR".
TYPE CODE ZERO CARRY NEG PARITY A-Register
INT 02 NZ C N E -1
STR 03 Z C P E 0
SNG 04 NZ C P O 1
DBL 08 NZ NC P E 5
Note: 40AFH holds Current number type flag.
DANDOR APPLIES THE "AND" AND "OR" OPERATORS AND SHOULD BE USED TO IMPLEMENT ALL LOGICAL OPERATORS. WHENEVER AN OPERATOR IS APPLIED, ITS PRECEDENCE IS IN [B]. THIS FACT IS USED TO DISTINGUISH BETWEEN "AND" AND "OR". THE RIGHT HAND ARGUMENT IS COERCED TO INTEGER, JUST AS THE LEFT HAND ONE WAS WHEN IT WAS PUSHED ON THE STACK.
25F7 - OR logic handler
25FD - AND logic handler
2603 - Dimension and Variable Searching
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2608 - DIM Routine
THE "DIM" CODE SETS DIMFLG AND THEN FALLS INTO THE VARIABLE SEARCH ROUTINE. THE VARIABLE SEARCH ROUTINE LOOKS AT DIMFLG AT THREE DIFFERENT POINTS:
- IF AN ENTRY IS FOUND, DIMFLG BEING ON INDICATES A "DOUBLY DIMENSIONED" VARIABLE
- WHEN A NEW ENTRY IS BEING BUILT DIMFLG'S BEING ON INDICATES THE INDICES SHOULD BE USED FOR THE SIZE OF EACH INDICE. OTHERWISE THE DEFAULT OF TEN IS USED.
- WHEN THE BUILD ENTRY CODE FINISHES, ONLY IF DIMFLG IS OFF WILL INDEXING BE DONE
260D - This is the variable location and creation logic.
This routine will return the address of a variable in memory or create it if it is not found. In order to use this routine, the HL must point to the variable name (ASCII). Then, after execution, HL will point to the character following the variable name and the location of the variable will be returned in the DE register pair. For integer, single or doubleprecision (NTF=2, 4 or 8) the address returned in DE will be the same as for the VARPTR command under BASIC. (see Level II BASIC manual on VARPTR) For strings (NTF=3) however the address returned in DE will point to the first of three bytes containing the string length and string address.
This entry point searches the Variable List Table (VLT) for a variable name which matches the name in the string pointed to by HL. If the variable exists, its address is returned in DE. If it is not defined, then it is created with an initial value ofzero and its address is returned in DE. Dimensioned and non-dimensioned variables may be located, and suffixs for data mode may be included in the name string. A byte of machine zeros must terminate the name string. All registers are used.
ROUTINE TO READ THE VARIABLE NAME AT THE CURRENT TEXT POSITION AND PUT A POINTER TO ITS VALUE IN [D,E]. [H,L] IS UPDATED TO POINT TO THE CHARACTER AFTER THE VARIABLE NAME. VALTYP IS SETUP. NOTE THAT EVALUATING SUBSCRIPTS IN A VARIABLE NAME CAN CAUSE RECURSIVE CALLS TO PTRGET SO AT THAT POINT ALL VALUES MUST BE STORED ON THE STACK. ON RETURN, [A] DOES NOT REFLECT THE VALUE OF THE TERMINATING CHARACTER
Note: 40AEH holds LOCATE/CREATE variable flag.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: 4101H-411AH holds Variable Declaration Table.
NOTE: 40AFH holds Current number type flag.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40DCH holds FOR flag.
Note: 40DCH holds FOR flag.
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
- Note: 40FBH-40FCH holds the starting address of the BASIC array variable storage area.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40FDH-40FEH holds Free memory pointer.
NOTE: 40FDH-40FEH holds Free memory pointer.
- Note: 40FBH-40FCH holds the starting address of the BASIC array variable storage area.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
26D5 - This routine is to locate a subscripted variable
NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).
The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
26E9 - This routine locates the address of a subscripted variable
On entry D = the type of variable, B = the 1st character of the variable name, C = the 2nd character of the variable name, and HL = the current position in the input string.
Note: 40AEH holds LOCATE/CREATE variable flag and will be a 0 if in locate mode and anything other than zero if in create mode.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: 40F3H-40F4H holds Temporary storage location.
NOTE: 40AEH holds LOCATE/CREATE variable flag.
AT THIS POINT [B,C]=LOOKS. THE TEXT POINTER IS IN TEMP2. THE INDICES ARE ALL ON THE STACK, FOLLOWED BY THE NUMBER OF DIMENSIONS.
- Note: 40FBH-40FCH holds the starting address of the BASIC array variable storage area.
Note: 40FDH-40FEH holds Free memory pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40AFH holds Current number type flag.
Note: 40AEH holds LOCATE/CREATE variable flag.
TEMP2=THE TEXT POINTER. WE HAVE LOCATED THE VARIABLE WE WERE LOOKING FOR AT THIS POINT [H,L] POINTS BEYOND THE SIZE TO THE NUMBER OF DIMENSIONS THE INDICES ARE ON THE STACK FOLLOWED BY THE NUMBER OF DIMENSIONS
273D - BS ERROR entry point
2742 - HERE WHEN VARIABLE IS NOT FOUND IN THE ARRAY TABLE
Note: 40D8H-40D9H holds temporary storage location.
Note: 40AEH holds LOCATE/CREATE variable flag.
Note: 40FDH-40FEH holds free memory pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40D8H-40D9H holds Temporary storage location.
AT THIS POINT [H,L] POINTS BEYOND THE SIZE TO THE NUMBER OF DIMENSIONS
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: 40AFH holds Current number type flag.
Note: 40F3H-40F4H holds Temporary storage location.
27C9-27D3 - LEVEL II BASIC MEM Routine
This is the RETURN AMOUNT OF FREE MEMORY routine at 27C9H which computes the amount of memory remaining between the end of the variable list and the end of the stack and puts the result in REG 1 as a SINGLE PRECISION number.
NOTE: 40AFH holds Current number type flag.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
27D4-27F4 - LEVEL II BASIC FRE ROUTINE
NOTE: 40FDH-40FEH holds Free memory pointer.
NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).
The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
NOTE: 40A0H-40A1H holds the start of string space pointer.
NOTE: 40D6H-40D7H holds Next available location in string space pointer.
This routine subtracts [D,E] from [H,L] and floats the result leaving it in FAC.
27F5-27FD - LEVEL II BASIC POS( ROUTINE
Note: 40A6H holds the current cursor line position.
27FE-2818 - LEVEL II BASIC USR(x) ROUTINE
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40AFH holds Current number type flag.
(02=INT, 03=STR, 04=SNG, 08=DBL).
- Note: 408EH-408FH holds the entry address of a machine language program to be called by a USR command.
2819-2827 - CONVERSION ROUTINE
Usually called by LET to convert the result of arithmetic routines to the proper destination type
(02=INT, 03=STR, 04=SNG, 08=DBL).
2828-2835 - Save the code string address
Usually called from the INPUT routine. On entry HL has the current line number in binary.
NOTE:40A2H-40A3H holds the current BASIC line number.
2831 - ID ERROR entry point.
2836-2856 - LEVEL II BASIC STR$ ROUTINE
STRCPY creates a copy of the string whose descriptor is pointed to by [H,L].
On return [D,E] points to DSCTMP which has the string info (length, where copied to)
2857-2864 - STRING ROUTINE - Set Up a String. A needs to hold the length of the string to be created
Note: 40D3H-40D5H holds Used for temporary string VARPTR's.
2865-28A5 - STRING ROUTINE
This is the quote routine. C will be a counter.
STRLT2 takes the string literal whose first character is pointed by [H,L]+1 and builds a descriptor for it.
The descriptor is initially built in DSCTMP, but PUTNEW transfers it into a temporary and leaves a pointer at the temporary in FACLO.
The characters other than zero that terminate the string should be set up in [B] and [D].
It the terminator is a quote, the quote is skipped over.
Leading quotes should be skipped before call.
On return the character after the string literal is pointed to by [H,L] and is in [A], but the condition codes are not set up.
Some string function is returning a result in DSCTMP.
We want to setup a temp descriptor with DCSTMP in it, put a pointer to the descriptor in FACLO and flag the result as type string
Note: 40D3H-40D5H holds Used for temporary string VARPTR's.
Note: 40B3H-40B4H holds Next available location in the temporary string work area pointer.
Note: 40AFH holds Current number type flag.
Note: 40D6H-40D7H holds Next available location in string space pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40B3H-40B4H holds Next available location in the temporary string work area pointer.
28A1 - ST ERROR entry point.
28A6-28BE - DISPLAY MESSAGE ROUTINE
Print the string pointed to by [H,L] which ends with a zero.
If the string is below DSCTMP it will be copied into string space
28A7 - This is a general purpose output routine.
It will output data to the display, printer or cassette, depending on the contents of 409CH. (0=video, -1=tape, 1=printer). The address of the first character in the string to be output must be in the HL register pair, and the string must end with a zero byte or a quote (22H).
Note: 409CH holds the current output device flag: -1=cassette, 0=video and 1=printer.
This is the WRITE MESSAGE routine, which displays message pointed to by HL on current system output device (usually video). The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D. If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0 (JP 5B99H). This subroutine uses th literal string pool table and the string area. It should not be called if the communications region and the string area are not properly maintained.
This routine has essentially the same effect as the routine at 2B75H, except that text may also end with a quotation mark (22H), creates string vector before output (destroys current contents of ACCUM, sets number type flag at 40AFH to 3 - see chapter two of this book), and also uses BC & DE registers. Depends heavily on BASIC string management routines (use of 2B75H or other routines may be preferable). If string contains a carriage return (ODH) character, a CALL will be made to the Disk BASIC link at 41DOH. Used by BASIC PRINT statement. This routine may also be entered at 28A6H, in which case the HL register pair will be incremented prior to beginning to output string.
To use a ROM call to display a string of characters starting at the current cursor position, and to update the cursor position,store the characters in consecutive memory locations, with a zero byte at the end, then load the HL register pair with the address of the first character of the string, and then CALL 28A7CALL STROUTH.
EXAMPLE: Suppose that we have the following symbolic setup:
TITL DEFM 'INSIDE LEVEL II'
DEFB 0
Then, the instructions:
LD HL,TITL
CALL 28A7CALL STROUTH
will cause "INSIDE LEVEL II" to be displayed at the current cursor position and the cursor position to be updated.
NOTE: If the subroutine at 28A7H is used by an assembly language program that is itself entered by a USR call, the return from the assembly language program may encounter the embarrassment of a TM error, with control passing to the Level II monitor. This occurs because the subroutine at 28A7H leaves a 3 in location 40AFH, while the USR structure requires a 2 in 40AFH upon returning. The malady is cured by storing a 2 in 40AFH before returning, or by jumping to 0A9AH instead of executing the simple RET. The problem would not occur in the first place if the assembly language program returns the value of an integer variable to the BASIC program, and it might not occur if some other ROM routine is called after the subroutine at 28A7H and before returning ? if the other subroutine produces an integer output. DISK SYSTEM CAUTION: See the DISK SYSTEM CAUTION of Section 8.1 regarding the exits to DISK BASIC from the subroutine at 28A7H.
28BF-28D9 - STRING ROUTINE - Compute the amount of space remaining in the string area.
GETSPA - get space for character string.
May force garbage collection.
# of chars (bytes) in [A].
Returns with pointer in [D,E] otherwise if cant get space blows off to "out of string space" type error.
Note: 40A0H-40A1H holds the start of string space pointer.
Note: 40D6H-40D7H holds Next available location in string space pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40D6H-40D7H holds Next available location in string space pointer.
28DA-298E - STRING ROUTINE
Note: 40B1H-40B2H holds MEMORY SIZE? pointer.
Note: 40D6H-40D7H holds Next available location in string space pointer.
NOTE: 40A0H-40A1H holds the start of string space pointer.
Note: 40B5H-40D2H holds Temporary string work area.
NOTE: 40B3H-40B4H holds Next available location in the temporary string work area pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: 40F9H-40FAH holds the starting address of the simple variable storage area.
- Note: 40FBH-40FCH holds the starting address of the BASIC array variable storage area.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40FDH-40FEH holds Free memory pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40D8H-40D9H holds Temporary storage location.
Note: 40D8H-40D9H holds Temporary storage location.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: 40D6H-40D7H holds Next available location in string space pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Here when made one complete pass thru string vars
NOTE: 40D6H-40D7H holds Next available location in string space pointer.
298F-29C5 - STRING ADDITION ROUTINE - Concatenate two strings
The following routine concatenates two strings.
The FACLO contains the first one at this point, [H,L] points beyond the + sign after it
29C6-29D6 - STRING ROUTINE - This will move strings using the stack
On entry, the stack should have the count/source address and DE should have the destination address.
29C8 - STRING MOVE ROUTINE
On entry HL points to the string control block for the string to be moved, and DE contains the destination address. All registers are used. The string length and address are not moved. String control blocks have the format: X=String Length; ADDR = String Address.
29D7-29F4 - FREE UP STRING TEMPORARY - FRESTR, FREFAC, FRETMP, FRETMS
FRETMP is passed a pointer to a string descriptor in [D,E].
This value is returned in [H,L].
All the other registers are modified.
A check to is made to see if the string descriptor [D,E] points to is the last temporary descriptor allocated by PUTNEW.
If so, the temporary is freed up by the updating of TEMPPT.
If a temporary is freed up, a further check is made to see if the string data that that string temporary pointed to is the the lowest part of string space in use.
If so, FRETMP is updated to reflect the fact that that space is no longer in use.
This routine is a contination of VAL, FRE, and PRINT processing. A jump to here would include the need to get a string's VARPTR and put it in HL.
Note: 40D6H-40D7H holds Next available location in string space pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40D6H-40D7H holds Next available location in string space pointer.
29F5-2A02 - STRING ROUTINE
Note: 40B3H-40B4H holds Next available location in the temporary string work area pointer.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40B3H-40B4H holds Next available location in the temporary string work area pointer.
2A03-2A0E - LEVEL II BASIC "LEN" ROUTINE
The function LEN($) returns the length of the string passed as an argument
2A0F-2A1E - LEVEL II BASIC "ASC" ROUTINE
The following is the ASC($) function.
It returns an integer which is the decimal ASCII equivalent
2A1F-2A2E - LEVEL II BASIC "CHR$" ROUTINE - "CHR$"
CHR$(#) creates a string which contains as its only character the ASCII equivalent of the integer arg (#) which must be .LE. 255.
2A2F-2A60 - LEVEL II BASIC "STRING$" ROUTINE - "STRNG$"
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).
The results are returned as follows:
| If the Variable Type is ... | and the Flags are set ... | ... then Register A will be set ... |
| Integer | NZ/C/M/E | -1 |
| String | Z/C/P/E | 0 |
| Single Precision | NZ/C/P/O | 1 |
| Double Precision | NZ/NC/P/E | 5 |
2A61-2A90 - LEVEL II BASIC "LEFT$(" ROUTINE - On entry, HL=address of LEFT$, the stack = string address, stack+1 = n, and DE = code string address - "LEFT$"
The following is the LEFT$($,#) function.
It takes the leftmost # chars of the str.
If # is .GT. than the len of the str, it returns the whole str.
This is print usings entry point into LEFT$
2A91-2A99 - LEVEL II BASIC RIGHT$ ROUTINE - "RIGHT$"
2A9A-2AC4 - LEVEL II BASIC MID$ ROUTINE - "MID$"
MID ($,#) returns str with chars from # position onward.
If # is GT LEN($) then return null string.
MID ($,#,#) returns str with chars from # position for #2 chars.
If #2 goes past end of string, return as much as possible.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2AC5-2ADE - LEVEL II BASIC "VAL" ROUTINE - "VAL"
The VAL function takes a string and turn it into a number by interpreting the ASCII digits.
Etc..
Except for the problem that a terminator must be supplied by replacing the character beyond the string, VAL is merely a call to floating input (FIN).
2ADF-2A6 - STRING ROUTINE - "PREAM"
This is called by LEFT$, MID$, and RIGHT$ to test for the ending ")" character. On entry, the stack has the string address, byte count, and return address. On exit the stack has the string address, DE and B each have the byte count.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
Used by MID$ for parameter checking and setup
2AE7H-2AEEH STRING FUNCTIONS - LEFT HAND SIDE MID$
2AEF-2AF7 - LEVEL II BASIC "INP" ROUTINE - "FNINP"
The following functions allow the user full access to the I/O ports.
INP(CHANNEL#) returns an integer which is the status of the channel.
OUT CHANNEL#,VALUE puts out the integer value on channel #.
It is a statement, not a function.
Note: 4093H-4095H holds INP routine.
2AF8-2B00 - LEVEL II BASIC "OUT" ROUTINE
Note: 4096H-4098H holds OUT routine.
2B01-2B0D - THIS IS THE CONSOLE (CHANNEL NUMBER,SENSE SWITCH SETTING) COMMAND.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
2B05 - This routine takes the value from the ACC, converts it to an integer value and places the result in the DE register pair. The Z flag will be set if the result in DE is smaller than or equal to 255 (FFH). (DE = INT (ACC)).
2B0E-2B16 - EVALUATE EXPRESSION ROUTINE - "OUT" continues here
2B17-2B1A - CHECK SYNTAX ROUTINE - This checks to see if the next character is a """ and contnues on to 2B1CH if it is, and errors out if it isn't.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2BlB-2B28 - EVALUATE EXPRESSION ROUTINE - This is called by "PRINT TAB".
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
2B1C - This routine converts a numeric ASCII string pointed to by the HL into a hexadecimal value and places the result in the A register.
If the result is larger than 255 (FFH) then an FC ERROR (Illegal function call) will be generated. After execution the HL will point to the delimiter. If the delimiter is a zero byte or a colon (3AH) then the Z flag will be set. Any other delimiter will cause the Z flag to be reset.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
2B29-2B2D - LEVEL II BASIC "LLIST" ROUTINE
This routine sets the output device flag to PRINTER and then flows through to the LIST command.
Note: 409CH holds the current output device flag: -1=cassette, 0=video and 1=printer.
2B2E-2B74 - LEVEL II BASIC "LIST" ROUTINE.
On entry the stack has the return address, then the first basic line number to be listed, then the last basic line number to be listed.
NOTE:40A2H-40A3H holds the current BASIC line number.
In NEWDOS 2.1, this is called from LIST processing.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40ECH-40EDH holds EDIT line number.
Note: 40A7H-40A8H holds the input Buffer pointer.
2B75-2B7D - DISPLAY MESSAGE ROUTINE - "LISPRT
This is the PRINT MESSAGE routine which writes string pointed to by HL to the current output device. String must be terminated by a byte of zeros. This call is different from 28A7H because it does not use the literal string pool area, but it does use the same display routine and it takes the same DOS Exit at 41C1H. Uses all registers. This routine can be called without loading the BASIC utility, if a C9H (RET) is stored in 41C1H.
This routine outputs a string to device indicated by device type flag stored at 409CH. String must end with zero byte. On entry, HL registers must point to address of start of string. Calls routine at 032AH.
2B7E-2BC5 - UNTOKENIZE ROUTINE - "BUFLIN"
This routine is called by LIST and EDIT. It moves the line pointed to by HL to the input buffer area and then expands each token into the appropriate key word.
Note: 40A7H-40A8H holds the input Buffer pointer.
Difference between M1 and M3 ROMs: This change is to the LIST command. JP 069AH in the Model III replaces LD D,0FFH followed by JR 2B8CH in the Model I.
Difference between M1 and M3 ROMs: Another change to LIST. In the Model I three instructions occupied this area: LD A,(HL); OR A; INC HL. In the Model III the INC HL instruction is moved to the beginning of the three.
Difference between M1 and M3 ROMs: The final change to LIST - a JP P,2B89H instruction in the Model I is changed to a JP 302DH instruction in the Model III.
The following code is for the delete range command.
Before the lines are deleted, 'OK' is typed.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
2BF5-2C1E - LEVEL II BASIC CSAVE ROUTINE
The CSAVE command writes a program onto cassette by dumping BASICs core.
The header is three 211's followed by a one character file name.
The end is three zeros in a row.
NOTE: 40A4H-40A5H holds the starting address of BASIC program text also known as the PROGRAM STATEMENT TABLE (PST).
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
2C1F-2CA4 - LEVEL II BASIC CLOAD ROUTINE
The CLOAD command clears core and then reads a program from cassette.
Since the links of the file on cassette will be wrong if the file was saved with a different version of BASIC FINI is jumped to.
A scratch is done at the start so restarts at 0 won't leave things in a garbage state.
If the CLOAD file name is preceded by a question mark then a "CVER" is done, which compares the file in core with the file on tape
Difference between M1 and M3 ROMs:Another change that originated in the "new" ROM Model I modified the CLOAD command (changed the order of portions of the CLOAD routine, disallowed CLOAD from cassette drive #2, etc.).
2CA5 - "BAD" message string.
NOTE: 40A4H-40A5H holds the starting address of BASIC program text also known as the PROGRAM STATEMENT TABLE (PST).
This loop is going to read a byte, compare it to the next byte in the program memory, jump away if it doesn't match AND CLOAD? was chosen, write (or overwrite) that byte to memory, check for a zero, and loop back if no zero was found.
- Note: 40F9H-40FAH holds the starting address of the simple variable storage area.
Difference between M1 and M3 ROMs: Also part of CLOAD, this change turns off the tape before printing READY on the video display. In the Model I, the code from 2C7AH - 2C82H consisted of the instructions LD HL,1929H; CALL 28A7CALL STROUTH, CALL 01F8H. In the Model III the CALL to 01F8H has been moved to the beginning of these instructions.
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
NOTE: 40A4H-40A5H holds the starting address of BASIC program text also known as the PROGRAM STATEMENT TABLE (PST).
Difference between M1 and M3 ROMs: This is part of the CLOAD? routine used when a bad byte has been read from the tape. In the Model I, a LD HL, 2CA5H instruction is found here (loads HL with the starting address of the "BAD" message), while the Model III uses a CALL 31BDH instruction, which does some housekeeping in addition to pointing HL to the "BAD" message.
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
2CA5-2CA9 - MESSAGE STORAGE LOCATION
2CAA-2CB0 - LEVEL II BASIC "PEEK" ROUTINE - On entry, REG 1 to have the peek location, and on exit Reg 1 to have the peeked value.
Note: In the 8K PEEK only accepts positive numbers up to 32767.
POKE will only take an address up to 32767, no fudging allowed.
The value is unsigned.
In the extended version negative numbers can be used to refer to locations higher than 32767.
The correspondence is given by subtracting 65536 from locations higher than 32767 or by specifying a positive number up to 65535.
2CB1-2CBC - LEVEL II BASIC "POKE" ROUTINE
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
2CBD-2E52 - LEVEL II BASIC "USING" ROUTINE
Come here after the "USING" clause in a PRINT statement is recognized.
The idea is to scan the USING string until the value list is exhausted, finding string and numeric fields to print values out of the list in, and just outputing any characters that aren't part of a print field.
NOTE: The RST 08H routine compares the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call.
- If there is a match, control is returned to the next execution address (i.e, the RST 08H instruction + 2) with the next symbol in the A Register and HL incremented by one.
- If the two characters do not match, a syntax error message is given and control returns to the Input Phase).
Note: 40DEH holds READ flag.
Note: 40DEH holds READ flag.
Since string field wasn't found, the "USING" string character count and the pointer into it's data must be restored and the "\" printed
Here to print the character in [A] since it wasn't part of any field
Here when a "." is seen in the "USING" string.
It starts a numeric field if and only if it is followed by a "#"
Check for the "^^^^" that indicates scientific notation
NOTE:
- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Note: 40DEH holds READ flag.
NOTE:
- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.
Since FRMEVL may have forced garbage collection we have to use the number of characters already scanned as an offset to the pointer to the "USING" string's data to get a new pointer to the rest of the characters to be scanned
Here when the "!" indicating a single character string field has been scanned
This loop will print all the spaces needed and then jump to 2DD3H
When a "+" is detected in the "USING" string if a numeric field follows a bit in [D] should be set, otherwise "+" should be printed.
Since deciding whether a numeric field follows is very difficult, the bit is always set in [D].
At the point it is decided a character is not part of a numeric field, this routine is called to see if the bit in [D] is set, which means a plus preceded the character and should be printed.
2E53-2FFA - LEVEL II BASIC "EDIT" ROUTINE
This is the EDIT <line number> command.
The EDIT command takes a single line number as its argument.
If the line does not exist, an undefined statement error is printed.
The line number of the line being edited is then typed and the user may enter one of the following edit codes to change the line.
A - Again edit the line.
All previous edits made during the edit are discarded, and editing is restarted on the line.
#C - Change the character in the line to one typed on the users terminal.
#D - Delete # characters from the line.
ISTR<ESC> - Insert the string STR at the current position in the line.
XSTR<ESC> - Prints the rest of the line and goes into insert mode (same as "I").
HSTR<ESC> - All characters to the right of the current position are deleted, and insert mode is entered.
The deleted characters are not echoed.
L - Type the remainder of the line and restart editing at the start of the line.
Q - Quit editing the line.
Any partial changes made to the line by the EDIT command are not retained, and the original line is left unchanged.
#S<CHAR> - Search forward in the line for the N'th occurance of the character <CHAR>, printing all characters passed over up to, but not including the character which terminates the search.
#K<CHAR> - Equivalent to "S" except that all characters passed over during the searche are deleted.
E - End editing the line.
The edited line replaces the orignginal line.
<CR> - Quit editing the line (print the remainder of the line).
The edited line replaces the original line.
[C] contains count of characters in line.
[B] contains current character position 0=first in line.
[H,L] point to current character
Note: 409AH holds the RESUME flag.
Note: 40EAH-40EBH holds the line number with error.
Now that the above code is out of the way (it was the code which would enter EDIT if there was an error in a line number), let us actually process the EDIT command.
Note: 40ECH-40EDH holds EDIT line number.
Note: 40A7H-40A8H holds the input Buffer pointer.
2F02 - "EDIT" Command - Cancel and Restore Logic.
2F0A - This routine prints a string of text to the display, printer or tape.
This routin uses 032AH to do this. HL must point to the first character of the string. (409CH must be set before calling this routine, see 32AH). String must be delimited with a zero byte.
Note: 409CH holds the current output device flag: -1=cassette, 0=video and 1=printer.
2F16 - "EDIT" Command - KILL Logic.
2F40 - "EDIT" Command - LIST Logic.
2F4A - "EDIT" Command - DELETE Logic.
2F65 - "EDIT" Command - CHANGE Logic.
2F75 - "EDIT" Command - HACK/INSERT Logic.
Now fall into the INSERT code
2F92 - "EDIT" Command - BACKSPACE CURSOR Logic.
Subroutine to delete char pointed to by [H,L]. Corrects C.
2FB0 - "EDIT" Command - ADD A CHARACTER Logic.
2FD2 - "EDIT" Command - BACKSPACE Logic.
Note: 40A7H-40A8H holds the input Buffer pointer.